package com.taobao.txc.resourcemanager.c;

import com.taobao.middleware.logger.Logger;
import com.taobao.txc.a.b.g;
import com.taobao.txc.common.LoggerInit;
import com.taobao.txc.common.b.c;
import com.taobao.txc.common.c.F;
import com.taobao.txc.common.c.v;
import com.taobao.txc.common.config.o;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;

public class a
{
  private static final Logger a = LoggerInit.c;
  private static ConcurrentHashMap<String, Boolean> b = new ConcurrentHashMap();
  private static a c = null;
  
  public static a a()
  {
    if (c == null) {
      synchronized (a.class)
      {
        if (c == null)
        {
          a locala = new a();
          locala.b();
          c = locala;
        }
      }
    }
    return c;
  }
  
  public void b()
  {
    Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new b(this), 0L, 100L, TimeUnit.MILLISECONDS);
  }
  
  private String a(F paramF)
  {
    String str = null;
    if ((paramF instanceof com.taobao.txc.common.c.b)) {
      str = g.a().l();
    } else if ((paramF instanceof v)) {
      try
      {
        if (g.a() != null) {
          str = g.a().l();
        }
      }
      catch (c localc) {}
    } else {
      a.warn(paramF.toString(), "unknown message error");
    }
    return StringUtils.isEmpty(str) ? "NULL" : str;
  }
  
  public void a(v paramv)
  {
    String str = a(paramv);
    if (b.get(str) != null)
    {
      a.info(paramv.toString(), String.format("%s fast failed", new Object[] { str }));
      throw new c("begin txc too frequently");
    }
  }
  
  public void a(v paramv, Throwable paramThrowable)
  {
    if ((paramThrowable instanceof c))
    {
      c localc = (c)paramThrowable;
      if ((localc.getMessage() != null) && (StringUtils.indexOf(localc.getMessage(), "begin txc too frequently") != -1))
      {
        String str = a(paramv);
        b.put(str, Boolean.valueOf(true));
      }
      throw localc;
    }
    throw new c(paramThrowable);
  }
  
  public void a(com.taobao.txc.common.c.b paramb)
  {
    String str = a(paramb);
    if (b.get(str) != null)
    {
      a.info(paramb.toString(), String.format("%s fast failed", new Object[] { str }));
      throw new c("begin txc too frequently");
    }
  }
  
  public void a(com.taobao.txc.common.c.b paramb, Throwable paramThrowable)
  {
    if ((paramThrowable instanceof c))
    {
      c localc = (c)paramThrowable;
      if ((localc.getMessage() != null) && (StringUtils.indexOf(localc.getMessage(), "begin txc too frequently") != -1))
      {
        String str = a(paramb);
        b.put(str, Boolean.valueOf(true));
        o.a().a(g.f(), localc.getMessage(), 1, g.c());
      }
      else if (localc.getMessage() != null)
      {
        o.a().a(g.f(), localc.getMessage(), 10, g.c());
      }
      throw localc;
    }
    if (paramThrowable.getMessage() != null) {
      o.a().a(g.f(), paramThrowable.getMessage(), 10, g.c());
    }
    throw new c(paramThrowable);
  }
}


/* Location:           C:\Users\ibm\Downloads\txc-yun-sample (1)\txc-yun-sample\lib\txc-client-2.0.72.jar
 * Qualified Name:     com.taobao.txc.resourcemanager.c.a
 * JD-Core Version:    0.7.0.1
 */